package cn.paul.junit;

import cn.paul.domain3.Clazz;
import cn.paul.domain3.Student;
import cn.paul.mapper.ClazzMapper;
import cn.paul.utils.SqlSessionUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.Test;

/**
 * Created by paul on 2017-06-23.
 */
public class One2ManyTest {
    @Test
    public void test1() {
        SqlSession sqlSession = SqlSessionUtils.getSession();
      Clazz clazz =sqlSession.getMapper(ClazzMapper.class).selectClazzById(1);
        System.out.println(clazz.getName());
        for(Student student:clazz.getStudents()){
            System.out.println(student);
        }
        sqlSession.commit();
        sqlSession.close();

    }
    @Test
    public void test2() {
        SqlSession sqlSession = SqlSessionUtils.getSession();
        Clazz clazz =sqlSession.getMapper(ClazzMapper.class).selectClazzById(1);
        System.out.println(clazz);
//        for(Student student:clazz.getStudents()){
//            System.out.println(student);
//        }
        sqlSession.commit();
        sqlSession.close();

    }
}
